package io.hx.modules.rep.service.impl;


import io.hx.modules.hos.dao.AppointmentDao;
import io.hx.modules.patient.dao.PatientUserDao;
import io.hx.modules.sys.dao.SysUserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.hx.common.utils.PageUtils;
import io.hx.common.utils.Query;

import io.hx.modules.rep.dao.DiagnosticDao;
import io.hx.modules.rep.entity.DiagnosticEntity;
import io.hx.modules.rep.service.DiagnosticService;


@Service("diagnosticService")
public class DiagnosticServiceImpl extends ServiceImpl<DiagnosticDao, DiagnosticEntity> implements DiagnosticService {

    @Autowired
    private PatientUserDao userDao;
    @Autowired
    private AppointmentDao appointmentDao;
    @Autowired
    private SysUserDao sysUserDao;
    @Autowired
    private DiagnosticDao diagnosticDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DiagnosticEntity> page = this.page(
                new Query<DiagnosticEntity>().getPage(params),
                new QueryWrapper<DiagnosticEntity>()
        );
        for (DiagnosticEntity record : page.getRecords()) {
            record.setUser(userDao.selectById(record.getUserId()));
            record.setAppointmentEntity(appointmentDao.selectById(record.getAppointmentId()));
            record.setSysUserEntity(sysUserDao.selectById(record.getSysUserId()));
        }

        return new PageUtils(page);
    }

    @Override
    public DiagnosticEntity queryOneById2(Integer id) {
        return diagnosticDao.queryOneById2(id);
    }

    @Override
    public BigDecimal queryMoneyAll() {
        return diagnosticDao.queryMoneyAll();
    }

    @Override
    public List<Integer> queryAmountAll() {
        return diagnosticDao.queryAmountAll();
    }

    @Override
    public List<DiagnosticEntity> queryByUserId(Integer userId) {
        return diagnosticDao.queryByUserId(userId);
    }
}
